{{template "common/header.html" .}}
{{template "common/nav.html" .}}

<section class="main">
    <div class="container">
        <div class="columns">
            <div class="column is-9">
                <div class="main-body">
                    <article class="article-item">

                        <div class="article-item-left">
                            <a href="{{baseUrl}}/user/{{.Article.User.Id}}" title="{{.Article.User.Nickname}}"
                               target="_blank">
                                <div class="avatar is-rounded" style="background-image:url('{{.Article.User.Avatar}}')">
                                </div>
                            </a>
                        </div>

                        <div class="article-item-right">
                            <div class="article-title">
                                <a href="{{baseUrl}}/article/{{.Article.ArticleId}}">{{.Article.Title}}</a>
                            </div>

                            <div class="article-meta">
                                <span class="article-meta-item"><a
                                            href="{{baseUrl}}/user/{{.Article.User.Id}}">{{.Article.User.Nickname}}</a></span>
                                {{if .Article.Category}}
                                    <span class="article-meta-item"><a
                                                href="{{categoryArticlesUrl .Article.Category.CategoryId 1}}">{{.Article.Category.CategoryName}}</a></span>
                                {{end}}
                                {{if .Article.Tags}}
                                    {{range .Article.Tags}}
                                        <span class="article-meta-item"><a
                                                    href="{{tagArticlesUrl .TagId 1}}">{{.TagName}}</a></span>
                                    {{end}}
                                {{end}}
                                <span class="article-meta-item"><time datetime="{{prettyTime .Article.CreateTime}}"
                                                                      itemprop="datePublished">{{prettyTime .Article.CreateTime}}</time></span>
                            </div>

                            <div class="article-tool">
                                {{if .CurrentUser}}
                                    {{if eq .CurrentUser.Id .Article.User.Id}}
                                        <span><i class="iconfont icon-delete"></i><a
                                                    href="javascript:delArticle({{.Article.ArticleId}})">删除</a></span>
                                        <span><i class="iconfont icon-edit"></i><a
                                                    href="{{baseUrl}}/article/edit/{{.Article.ArticleId}}">修改</a></span>
                                    {{end}}
                                {{end}}
                                <span><i class="iconfont icon-favorite"></i><a
                                            href="javascript:addFavorite({{.Article.ArticleId}})">收藏</a></span>
                            </div>
                        </div>

                        <div class="article-content content">
                            {{if .Article.Share}}
                                <a class="article-share-summary"
                                   href="{{baseUrl}}/article/redirect/{{.Article.ArticleId}}"
                                   target="_blank">{{.Article.Summary}}</a>

                                <a href="{{baseUrl}}/article/redirect/{{.Article.ArticleId}}"
                                   target="_blank">点击阅读原文>></a>
                            {{else}}
                                {{.Article.Content}}
                            {{end}}
                        </div>

                        <div class="article-footer">

                            <blockquote>
                                <ul>
                                    {{if not .Article.Share}}
                                        <li>
                                            <strong>本文链接：</strong>
                                            <a href="{{baseUrl}}/article/{{.Article.ArticleId}}"
                                               title="{{.Article.Title}}"
                                               target="_blank"
                                               rel="external">{{baseUrl}}/article/{{.Article.ArticleId}}</a>
                                        </li>
                                        <li>
                                            <strong>版权声明： </strong>所有文章除特别声明外，均采用 <a
                                                    href="http://creativecommons.org/licenses/by/4.0/deed.zh"
                                                    target="_blank"
                                                    rel="external nofollow">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
                                        </li>
                                    {{end}}
                                    <li class="post-copyright-link hidden-xs">
                                        <strong>免责声明：</strong>
                                        我们尊重原创，也注重分享。版权原作者所有，如有侵犯您的权益请及时联系（<a
                                                href="mailto:mlog1@qq.com">mlog1@qq.com</a>），我们将在24小时之内删除。
                                    </li>
                                </ul>
                            </blockquote>

                        </div>

                    </article>

                    {{template "comment/index.html" .}}

                    <div class="columns article-related">
                        <div class="column">
                            {{if .NewestArticles}}
                                <div class="widget">
                                    <div class="header">最新文章</div>
                                    <div class="content">
                                        <ul>
                                            {{range .NewestArticles}}
                                                <li>
                                                    <a href="{{articleUrl .ArticleId}}" title="{{.Title}}"
                                                       target="_blank">{{.Title}}</a>
                                                </li>
                                            {{end}}
                                        </ul>
                                    </div>
                                </div>
                            {{end}}
                        </div>
                        <div class="column">
                            {{if .RelatedArticles}}
                                <div class="widget">
                                    <div class="header">相关文章</div>
                                    <div class="content">
                                        <ul>
                                            {{range .RelatedArticles}}
                                                <li>
                                                    <a href="{{articleUrl .ArticleId}}" title="{{.Title}}"
                                                       target="_blank">{{.Title}}</a>
                                                </li>
                                            {{end}}
                                        </ul>
                                    </div>
                                </div>
                            {{end}}
                        </div>
                    </div>

                </div>
            </div>
            <div class="column is-3">
                <div class="main-aside">

                    <div class="widget">
                        <div class="header">{{.Article.User.Nickname}}</div>
                        <div class="content">
                            <div>
                                <span>
                                    <i class="iconfont icon-username"></i>
                                    <a href="{{baseUrl}}/user/{{.Article.User.Id}}">{{.Article.User.Nickname}}</a>
                                </span>
                            </div>
                            <a href="{{baseUrl}}/user/{{.Article.User.Id}}" title="{{.Article.User.Nickname}}"
                               target="_blank">
                                <div class="avatar"
                                     style="width:150px; height: 150px; background-image: url('{{.Article.User.Avatar}}');">
                                </div>
                            </a>
                            {{if .Article.User.Description}}
                                <p>{{.Article.User.Description}}</p>
                            {{end}}
                        </div>
                    </div>

                    {{if .Article.Toc}}
                        <div class="toc widget">
                            <div class="header">目录</div>
                            <div class="content">
                                {{.Article.Toc}}
                            </div>
                        </div>
                    {{end}}

                    {{/*
                    {{if eq .Article.User.Type 1}}
                    <div class="widget">
                        <div class="header">关注公众号</div>
                        <div class="content">
                            <img src="https://open.weixin.qq.com/qr/code?username={{.Article.User.Username}}" />
                        </div>
                    </div>
                    {{end}}
                    */}}
                </div>
            </div>
        </div>
    </div>
</section>


{{/*高亮*/}}
<link href="//cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel="stylesheet">
<script src="//cdn.bootcss.com/highlight.js/8.0/highlight.min.js"></script>
<script type="text/javascript">
  // 高亮
  hljs.initHighlightingOnLoad()

  // 处理toc目录
  handleToc('.toc')

  // 删除文章
  function delArticle(articleId) {
    httpPost('{{baseUrl}}/article/delete/' + articleId)
      .then(function (data) {
        alert('删除成功')
      }, function (response) {
        alert(response.message)
      })
  }

  // 收藏
  function addFavorite(articleId) {
    httpPost('{{baseUrl}}/article/favorite/' + articleId)
      .then(function (data) {
        alert('收藏成功')
      }, function (response) {
        console.error(response)
      })
  }
</script>

{{template "common/footer.html" .}}
